home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-06-19 | 2.6 KB | 92 lines |
- package symantec.itools.awt.util;
-
-
- import java.awt.Canvas;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
-
- // 01/29/97 TWB Integrated changes from Macintosh
-
- /**
- * ToolBarPanelSpacer component.
- * This component is used to space items in a ToolBarPanel.
- * @see symantec.itools.awt.util.ToolBarPanel
- * @version 1.0, Nov 26, 1996
- * @author Symantec
- */
-
-
- public class ToolBarSpacer
- extends Canvas
- {
- /**
- * Create a ToolBarSpacer.
- */
- public ToolBarSpacer()
- {
- }
-
- /**
- * Paints this component using the given graphics context.
- * This is a standard Java AWT method which typically gets called
- * by the AWT to handle painting this component. It paints this component
- * using the given graphics context. The graphics context clipping region
- * is set to the bounding rectangle of this component and its <0,0>
- * coordinate is this component's top-left corner.
- *
- * Fills the spacer's area with the background color.
- *
- * @param g the graphics context used for painting
- * @see java.awt.Component#repaint
- * @see java.awt.Component#update
- */
- public void paint(Graphics g)
- {
- Dimension d = size();
- g.clipRect(0, 0, d.width, d.height);
- g.setColor(super.getBackground());
- g.fillRect(0, 0, d.width, d.height);
- }
-
- /**
- * Returns the recommended dimensions to properly display this component.
- * This is a standard Java AWT method which gets called to determine
- * the recommended size of this component.
- *
- * @return the width of this component and a height of tallest component the
- * ToolBarPanel.
- *
- * @see #minimumSize
- */
- public synchronized Dimension preferredSize()
- {
- Dimension s = this.size();// we want to retain user's width
- s.height = 10; // ... but constrain the height
-
- Component[] list = getParent().getComponents();
-
- for (int i = 0; i < list.length; ++i) {
- Component c = list[i];
- if (!(c instanceof ToolBarSpacer))
- s.height = Math.max(s.height, c.size().height);
- }
-
- return s;
- }
- /**
- * Returns the minimum dimensions to properly display this component.
- * This is a standard Java AWT method which gets called to determine
- * the minimum size of this component.
- *
- * In this case the minimum size is the same as the preferred size.
- *
- * @see #preferredSize
- */
- public synchronized Dimension minimumSize()
- {
- return preferredSize();
- }
- }
-
-